/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Tuan Long
 */
@Entity
@Table(name = "EventRegistration")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EventRegistration.findAll", query = "SELECT e FROM EventRegistration e"),
    @NamedQuery(name = "EventRegistration.findById", query = "SELECT e FROM EventRegistration e WHERE e.id = :id"),
    @NamedQuery(name = "EventRegistration.findByTimeRegisted", query = "SELECT e FROM EventRegistration e WHERE e.timeRegisted = :timeRegisted")})
@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(name="EventRegistration.getRegisters",procedureName = "sp_getRegisters",parameters = {
       @StoredProcedureParameter(name="eventId",mode=ParameterMode.IN,type=Integer.class)})
})
public class EventRegistration implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TimeRegisted")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeRegisted;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne(optional = false)
    private EventLibrary eventId;
    @JoinColumn(name = "Username", referencedColumnName = "Username")
    @ManyToOne(optional = false)
    private Employee username;

    public EventRegistration() {
    }

    public EventRegistration(Integer id) {
        this.id = id;
    }

    public EventRegistration(Integer id, Date timeRegisted) {
        this.id = id;
        this.timeRegisted = timeRegisted;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getTimeRegisted() {
        return timeRegisted;
    }

    public void setTimeRegisted(Date timeRegisted) {
        this.timeRegisted = timeRegisted;
    }

    public EventLibrary getEventId() {
        return eventId;
    }

    public void setEventId(EventLibrary eventId) {
        this.eventId = eventId;
    }

    public Employee getUsername() {
        return username;
    }

    public void setUsername(Employee username) {
        this.username = username;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventRegistration)) {
            return false;
        }
        EventRegistration other = (EventRegistration) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.EventRegistration[ id=" + id + " ]";
    }
    
}
